#!/bin/bash

logs_path=/soft/nginx/logs
old_logs_path=/home/rettc/logs

d=$(date -d "yesterday" +%Y%m%d)
mv $logs_path/access.log $old_logs_path/access_${d}.log
mv $logs_path/error.log $old_logs_path/error_${d}.log

kill -USR1 `ps axu | grep "nginx: master process" | grep -v grep | awk '{print $2}'`

cd $logs_path

find . -mtime +7 -name "*20[1-9][3-9]*" | xargs rm -f

